using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using Nextel.SatPublicidad.BL;
//using Nextel.SatPublicidad.BE;
using System.IO;
using System.Collections.Generic;
using System.Text;

public partial class RepFoto : PageController
{

    private void subScriptFoto()
    {
        StringBuilder sbScript = new StringBuilder();
        sbScript.Append("\n");
        sbScript.Append("<script language=JavaScript>\n");
        sbScript.Append("function seleccionar(IdFoto)\n");
        sbScript.Append("{\n");
        sbScript.Append("Principal.location.href ='RepFotoFrame.aspx?IdFoto=' + IdFoto');}\n");
        sbScript.Append("</script>");
        sbScript.Append("\n");
        ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page), "abrirPopUpModalID", sbScript.ToString());
    }

    protected override void initialize()
    {
        //-------------------------------------------
        //Declaracion de Variables
        //-------------------------------------------
        Int32 liIdFoto = Int32.Parse(Request.QueryString["IdFoto"]);
        byte[] imageData = null;
        MemoryStream ms = null;
        ////-------------------------------------------
        ////Selecccionar el array de bite
        ////-------------------------------------------

        if (liIdFoto > 0)
        {

            imageData = ((List<FotoDato>)Session["Fotos"])[liIdFoto - 1].Foto;

            if (imageData != null)
            {
                //-------------------------------------------
                //Colocarlo en un memorystream y luego en un Image
                //-------------------------------------------
                //byte[] arr = new byte[5];
                //arr[0] = (byte)4;
                //arr[1] = (byte)1;
                //arr[2] = (byte)2;
                //arr[3] = (byte)1;
                //arr[4] = (byte)4;

                ms = new MemoryStream(imageData);
                //ms = new MemoryStream(arr);
                System.Drawing.Image loDrawImage = System.Drawing.Image.FromStream(ms);

                //-------------------------------------------
                //Decirle al Image que pinte en la pagina
                //-------------------------------------------

                Response.ContentType = "image/jpeg";

                loDrawImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
        }
    } 
}
